package com.jd.sunny.java.collection;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @Description:
 * @author:sunlin
 * @since:2012-12-06 19:52
 * @version:1.0.0
 */
public class TestLinkedHashMap {

    public static void main(String[]args){
        //cache
        Map<String,Object>  cache = new LinkedHashMap<String,Object>(128,0.57F,true){
            /**
             * define when to remove eldest entry
             * here wo only save 100 entry
             * if need remove the eldest entry ,return true,otherwise,return false
             * @param eldest
             * @return
             */
            @Override
            protected boolean removeEldestEntry(Map.Entry<String,Object> eldest) {
                return size() > 100;
            }
        };
    }

}
